﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TCHSHue.BLL;

namespace TCHSHue.Modules.AdminControl.LKWebSite
{
    public partial class ctrLKWSList : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            NapDanhSachLK();
        }

        private void NapDanhSachLK()
        {
            var ls = LKWSBLL.getList();
            gridLK.DataSource = ls;
            gridLK.DataBind();
        }

        protected void RedirectEdit(object sender, CommandEventArgs e)
        {
            Response.Redirect("~/Modules/Admin.aspx?mode=chinhlk&id=" + e.CommandArgument.ToString());
        }

        protected void Delete(object sender, CommandEventArgs e)
        {
            if (!LKWSBLL.delete(e.CommandArgument.ToString()))
                Page.RegisterClientScriptBlock("XoaLK", "<SCRIPT Language='JavaScript'> alert('Không thể xóa liên kết này'); </SCRIPT>");
            else
                NapDanhSachLK();
        }
    }
}